﻿<helpers:BindablePage x:Name="bindablePage"
    x:Class="BalanceManager.Views.ItemsView"
                      DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=ItemsViewModel}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helpers="clr-namespace:BalanceManager.Helpers"
    xmlns:vm="clr-namespace:BalanceManager.ViewModels"
    xmlns:bar="clr-namespace:BindableApplicationBar;assembly=BindableApplicationBar"
    xmlns:uiControls="clr-namespace:BalanceManager.UIControls"
    xmlns:converters="clr-namespace:BalanceManager.Helpers.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True" BackKeyPress="BindablePage_BackKeyPress" Loaded="BindablePage_Loaded" LayoutUpdated="BindablePage_LayoutUpdated" BeginLayoutChanged="BindablePage_BeginLayoutChanged">

    <!-- Animated page transition -->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn" />
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn" />
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut" />
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    
    <helpers:BindablePage.Resources>
        <converters:BoolToVisibilityConverter x:Key="BoolToVisConverter" />
    </helpers:BindablePage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="#313131">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="категории" Style="{StaticResource PhoneTextLargeStyle}"/>
            <TextBlock Text="{Binding SelectedNodePath}" Style="{StaticResource PhoneTextSmallStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
            <uiControls:ExtendedLongListSelector ItemsSource="{Binding ItemsTree}" x:Name="treeListControl" Tap="TreeListControl_OnTap">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <!--<toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu>
                                    <toolkit:MenuItem Tag="{Binding Item}" Header="Редактировать" Click="MenuItem_Edit_OnClick"/>
                                    <toolkit:MenuItem Header="Удалить" Click="MenuItem_Delete_OnClick"  />
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
-->
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Column="0" Margin="10,15,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" Text="{Binding Item.Name}" />
                        </Grid>

                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </uiControls:ExtendedLongListSelector>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton IconUri="/Images/add.png" Text="Новый" Click="ApplicationBarIconButtonAdd_OnClick"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</helpers:BindablePage>